home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip: 2001 Haziran
/
CHIP Haziran2001.iso
/
prog
/
haziran
/
19
/
setup.exe
/
data.z
/
int_lib.bas
< prev
next >
Wrap
BASIC Source File
|
2001-04-11
|
3KB
|
103 lines
Attribute VB_Name = "int_lib"
'
' File - int_lib.bas
'
' This application catches interrupts that are genereted by the
' computer components, and is controlled via a graphical user
' interface - int_gui.frm
' The interrupts are detected using WinDriver functions.
'
Option Explicit
Private g_cardReg As WD_CARD_REGISTER
Private g_phThread As Long
Global g_intrp As WD_INTERRUPT
Sub Int_Handler(ByVal pData As Long)
int_gui.IntCount = g_intrp.dwCounter
int_gui.IntCount.Refresh
End Sub
Function Interrupt_Thread_Enable(hWD As Long, intrp As WD_INTERRUPT, CurIrq As Integer) As Boolean
g_phThread = 0
g_cardReg.Card.dwItems = 1
g_cardReg.Card.Item(0).Item = ITEM_INTERRUPT
g_cardReg.Card.Item(0).fNotSharable = False
g_cardReg.Card.Item(0).dw1 = CurIrq
g_cardReg.Card.Item(0).dw2 = 0
g_cardReg.fCheckLockOnly = False
WD_CardRegister hWD, g_cardReg
If (g_cardReg.hCard = 0) Then
MsgBox "Failed locking device", vbCritical + vbOKOnly, "Interrupt listener"
GoTo Error
Else
intrp.hInterrupt = g_cardReg.Card.Item(0).dw3
intrp.dwCmds = 0
intrp.dwOptions = 0
End If
If (InterruptThreadEnable(g_phThread, hWD, intrp, _
AddressOf Int_Handler, 0, int_gui.hWnd) = 0) Then
MsgBox "Failed enabling interrupt. Interrupt already in use", vbCritical + vbOKOnly, "Interrupt listener"
GoTo Error
End If
' Thread was created succesfuly
Interrupt_Thread_Enable = True
GoTo finish
Error:
' Error during open
If (g_cardReg.hCard <> 0) Then
WD_CardUnregister hWD, g_cardReg
End If
Interrupt_Thread_Enable = False
finish:
End Function
Sub Interrupt_Thread_Disable(hWD As Long)
If (g_phThread <> 0) Then
InterruptThreadDisable g_phThread
End If
If (g_cardReg.hCard <> 0) Then
WD_CardUnregister hWD, g_cardReg
End If
End Sub
Function Int_Open(hWD As Long) As Boolean
Dim verBuf As WD_Version
hWD = WD_Open()
If (hWD = INVALID_HANDLE_VALUE) Then
MsgBox "ERROR opening WinDriver", vbCritical + vbOKOnly, "Interrupt listener"
GoTo Error
End If
WD_Version hWD, verBuf
If (verBuf.dwVer < WD_VER) Then
MsgBox "ERROR incorrect WinDriver version. needs ver " & WD_VER & Chr$(13) _
& "You are using WINDRVR version " & verBuf.dwVer, vbOKOnly, "Error"
GoTo Error
End If
' Open finished OK
Int_Open = True
GoTo finish
Error:
' Error during open
If (hWD <> INVALID_HANDLE_VALUE) Then
WD_Close hWD
End If
Int_Open = False
finish:
End Function
Sub Int_Close(hWD As Long)
If (hWD <> INVALID_HANDLE_VALUE) Then
WD_Close (hWD)
End If
End Sub